import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getx_learn/app/common/widgets/widgets.dart';
import 'package:getx_learn/app/modules/state_manager_demo/modules/getx_service_demo/services/GlobalConfigService.dart';

import '../controllers/getx_service_demo_controller.dart';

class GetxServiceDemoView extends GetView<GetxServiceDemoController> {
  const GetxServiceDemoView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(context: context, title: "GetxServiceDemoView"),
      body: ListView(
        children: [
          Text("""
          生命周期跟程序一致，主要用来将全局需要使用的数据存到这里
          """),
          Divider(),
          // Service Global Config
          ListTile(
            title: Text("Service Global Config -> channel"),
            subtitle: Text(
                "channel : " + Get.find<GlobalConfigService>().channel.value),
          ),
          Divider(),
          ListTile(
            title: Text("Service Global Config -> isIOS"),
            subtitle: Text("isIOS : " +
                Get.find<GlobalConfigService>().isIOS.value.toString()),
          ),
          Divider(),


          Obx((){
            return ListTile(
              title: Text("Service Global Config -> count1"),
              subtitle: Text("count1 : " +
                  Get.find<GlobalConfigService>().count1.toString()),
            );
          }),

          ElevatedButton(
              onPressed: () {
                Get.find<GlobalConfigService>().getCounter();
                Get.find<GlobalConfigService>().getCount1();
              },
              child: Text("点我加1"))
        ],
      ),
    );
  }
}
